const formatNumber=n=>{
	n=n.toString()
	return n[1]?n:`0${n}`
}

const formatTime =date=>{
	let year=date.getFullYear()
	let month=date.getMonth()+1
	let day=date.getDate()
	let hour=date.getHours()
	let minute=date.getMinutes()
	let second=date.getSeconds()
	return ` ${[year,month,day].map(formatNumber).join('-')} ${[hour,minute,second].map(formatNumber).join(':')}`
}
/**
 * 检查某字段长度是否满足要求
 * @param {Object} filed 要检查的对象
 * @param {Number} length 必须满足的长度
 * @param {String} name 该字段中文名称
 * @returns 返回结果是否合法
 */
function checkLength(filed,length,name){
	if(filed.length>=length){
		return true
	}
	let message=name+"不能少于"+length+"个字符"
	if(filed.length==0){
		message=name+"不能为空"
	}
	uni.showToast({
		title:message,
		icon:'error'
	});
	return false
}
	module.exports={
		formatTime,
		checkLength,
		
	}